/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package nominalitzacions.ui;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BoxLayout;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;

/**
 *
 * @author marc.mauri
 */
public class DictionaryEditor extends JFrame {

    private DictionaryEditorController DEC;
    private DefaultListModel listModel;

    public DictionaryEditor(Object[] data) {
        super();

        DEC = new DictionaryEditorController();

        this.setTitle("Dictionary Editor - Nominalizator");

        JPanel mainPanel = new JPanel();
        mainPanel.setLayout(new BorderLayout() );

        JList dictionary = new JList(data);
        listModel = new DefaultListModel();
        dictionary.setModel(listModel);
        JScrollPane scrollDictionary = new JScrollPane(dictionary);
        scrollDictionary.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        mainPanel.add(scrollDictionary, BorderLayout.CENTER);


        JPanel eastPanel = new JPanel();
        eastPanel.setLayout(new BoxLayout(eastPanel, BoxLayout.PAGE_AXIS) );

        JButton addButton = new JButton("Add");
        addButton.setAlignmentX(CENTER_ALIGNMENT);
        addButton.setAlignmentY(TOP_ALIGNMENT);
        addButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                DEC.add();
            }
        });
        eastPanel.add(addButton);

        JButton editButton = new JButton("Edit");
        editButton.setAlignmentX(CENTER_ALIGNMENT);
        editButton.setAlignmentY(TOP_ALIGNMENT);
        /*editButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                DEC.edit();
            }
        });*/
        eastPanel.add(editButton);

        JButton removeButton = new JButton("Erase");
        removeButton.setAlignmentX(CENTER_ALIGNMENT);
        removeButton.setAlignmentY(TOP_ALIGNMENT);
        /*editButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                DEC.remove();
            }
        });*/
        eastPanel.add(removeButton);

        mainPanel.add(eastPanel, BorderLayout.EAST);

        JPanel southPanel = new JPanel();
        southPanel.setLayout(new FlowLayout() );

        JButton acceptButton = new JButton("Accept");
        /*acceptButton.addActionListener(new ActionListener() {
           public void actionPerformed(ActionEvent evt) {
               DEC.accept()
           }
        });*/
        southPanel.add(acceptButton);

        JButton cancelButton = new JButton("Cancel");
        /*acceptButton.addAction(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                cancel();
            }
        });*/
        southPanel.add(cancelButton);

        mainPanel.add(southPanel, BorderLayout.SOUTH);

        this.setContentPane(mainPanel);
        this.setSize(400, 300);
        this.setResizable(false);
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setVisible(true);
    }
    public void setVisible() {
        System.out.println("jsah if");
        this.pack();
        this.setVisible(true);
    }

}

